package com.midea.ai.air.ui.more.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.midea.ai.air.R;
import com.midea.ai.air.ui.more.data.FamilyMember;
import com.midea.ai.air.ui.more.data.MoreDetailedItem;
import com.midea.ai.air.ui.more.data.MyFamily;
import com.midea.ai.air.view.SwipeItemView;

import java.util.List;

/**
 * Created by hww on 2016/4/20.
 */
public class MoreSettingBrainpowerSelectRoomAdapter extends ArrayAdapter<FamilyMember> {

    private LayoutInflater mLayoutInflater;
    private Context mContext;

    public MoreSettingBrainpowerSelectRoomAdapter(Context context, List<FamilyMember> objects) {
        super(context, 0, objects);
        mLayoutInflater = LayoutInflater.from(context);
        mContext = context;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder holder;
        FamilyMember item = getItem(position);
        if (convertView == null) {
            convertView = mLayoutInflater.inflate(R.layout.item_list_family, null);
            holder = new ViewHolder();
            holder.Img = (ImageView) convertView.findViewById(R.id.imgView_icon);
            holder.content = (TextView) convertView.findViewById(R.id.txtView_name);
            holder.botLine = convertView.findViewById(R.id.bottom_line);
            convertView.setTag(holder);
        } else {
            holder = (ViewHolder) convertView.getTag();
        }

        holder.Img.setImageResource(item.getHeadIconResId());
        holder.content.setText(item.getStrName());
        if (position == getCount() - 1) {
            holder.botLine.setVisibility(View.GONE);
        } else {
            holder.botLine.setVisibility(View.VISIBLE);
        }
        return convertView;
    }

    class ViewHolder {
        private ImageView Img;
        private TextView content;
        public View botLine;
    }
}
